Skip to content

Conversation

@joaoGabriel55
Copy link

Issue: #1932

🎯 Changes

  • Add support for file values with UUID in setFieldValue

βœ… Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

πŸš€ Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

⚠️ No Changeset found

Latest commit: df74f02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

* @private
*/
export function setBy(obj: any, _path: any, updater: Updater<any>) {
const isFile = updater instanceof File
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Native does not have File defined and will throw a ReferenceError. You cannot implement the fix this way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Truly. Good catch, thanks!

@nx-cloud
Copy link

nx-cloud bot commented Dec 17, 2025

View your CI Pipeline Execution β†— for commit df74f02

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... βœ… Succeeded 2m 50s View β†—
nx run-many --target=build --exclude=examples/** βœ… Succeeded 34s View β†—

☁️ Nx Cloud last updated this comment at 2025-12-19 08:23:26 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 17, 2025

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@1939

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@1939

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@1939

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@1939

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@1939

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@1939

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@1939

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@1939

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@1939

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@1939

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@1939

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@1939

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@1939

commit: df74f02

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.
βœ… Project coverage is 89.25%. Comparing base (6892ed0) to head (df74f02).
⚠️ Report is 111 commits behind head on main.

Files with missing lines Patch % Lines
packages/form-core/src/utils.ts 66.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1939      +/-   ##
==========================================
- Coverage   90.35%   89.25%   -1.11%     
==========================================
  Files          38       48      +10     
  Lines        1752     1954     +202     
  Branches      444      498      +54     
==========================================
+ Hits         1583     1744     +161     
- Misses        149      189      +40     
- Partials       20       21       +1     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…trigger-rerender' of github-personal.com:joaoGabriel55/form into fix/file-input-field-picking-a-different-file-does-not-trigger-rerender
Copy link
Contributor

@LeCarbonator LeCarbonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the previous comment hasn't been addressed between the previous review and this review request.

The actual required changes don't look that bad, though. Perhaps I'll have some time to help out later this week with that.

if (!path.length) {
return functionalUpdate(updater, parent)
return functionalUpdate(
isFile(updater) ? { file: updater, uuid: uuid() } : updater,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't type safe. This wrongly asserts File field values as { file: File | (oldFile: File) => File, uuid: string } instead of

  1. actually running the updater
  2. Preserving the expected field value's structure

}

export function evaluate<T>(objA: T, objB: T) {
if (objA instanceof File && objB instanceof File) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the previous comment wasn't addressed, despite the request for another review. This will throw ReferenceErrors in environments where File is not present (such as React Native).

const firstFile = new File(['first'], 'first.png', { type: 'image/png' })
form.setFieldValue('avatar', firstFile)

const firstValue = form.state.values.avatar as { file: File; uuid: string }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These type assertions are a huge problem. It cannot stay.

Luckily, as long as evaluate properly handles File types, this whole uuid trickery won't be needed. Just make sure to add unit tests for a File comparison with evaluate. I believe the existing tests can be found in utils.spec.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants